package com.gviiii.baiduai.ai;

import com.gviiii.baiduai.config.ServiceConfig;
import com.gviiii.baiduai.pojo.FileInfo;
import com.gviiii.baiduai.pojo.ImageResultInfo;
import com.gviiii.baiduai.util.FileUtil;

import java.util.HashMap;
import java.util.Map;

public abstract class AbstractAiImageService extends AbstractAiService {

    public AbstractAiImageService() {
    }

    /**
     * @param fileInfo
     * @param api
     * @param threshold
     */
    @Override
    protected void distinguish(FileInfo fileInfo, String api, double threshold) {
        Map map = new HashMap();
        map.put("image", FileUtil.encodeFiles(fileInfo.getFilePath()));
        distinguish(map);
    }

    /**
     * @param serviceConfig
     * @param fileInfo
     * @param resultsBean
     * @param i
     */
    @Override
    protected void switchImgsDir(ServiceConfig serviceConfig, FileInfo fileInfo, ImageResultInfo.ResultsBean resultsBean, int i) {
        if (resultsBean.getScore() > 0.5) {
            copyImageFile(serviceConfig.getResultMap(),fileInfo,resultsBean);
        }
    }
}
